import { wash as washInfo } from '../services/washer';

export default {
  namespace: 'washer',

  state: {
    resultContent: '',
    resultRatio: '',
  },

  effects: {
    *wash({ payload }, { call, put }){
      const response = yield call(washInfo, payload);
      yield put({
        type: 'loadResult',
        payload: response.data,
      });
    },
  },

  reducers: {
    loadResult(state, action){
      return {
        ...state,
        resultContent: action.payload.content,
        resultRatio: action.payload.ratio,
      }
    },
  },
};
